/*
嵌入式php
*/
#include <stdio.h>

#define ZEND_DEBUG 1

#include <sapi/embed/php_embed.h>

void dump_zval( zval* zv);
static int embed3_ub_write(const char *str, unsigned int str_length TSRMLS_DC);

int main(int argc ,char *argv[])
{
	char *command_string = "function foo(){ \
               echo \"hello world\n\"; \
               print(\"test\n\"); \
             } ; foo(); ";

#ifdef ZTS
    void ***tsrm_ls;
#endif
	php_embed_module.php_ini_path_override = "/usr/local/lib/php.ini";
	php_embed_module.ub_write = embed3_ub_write; //指向函数的指针
	php_embed_init(argc, argv PTSRMLS_CC);
    
    zend_first_try {
        zend_eval_string( command_string , NULL ,"Embed string" TSRMLS_CC);
    } zend_end_try();
    
    php_embed_shutdown(TSRMLS_C);
    return 0;
}
//*输出*//
static int embed3_ub_write(const char *str, unsigned int str_length TSRMLS_DC)
{
	printf("%s",str);
	return str_length;
}


